package ssx.demo.springbootmysqlcurd.service;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import ssx.demo.springbootmysqlcurd.dao.IDao;
import ssx.demo.springbootmysqlcurd.entity.UserPOJO;
import ssx.demo.ssxutils.multitask.MultiUtil;
import java.util.List;

@org.springframework.stereotype.Service
public class Service {
    @Autowired
    private IDao iDao;

    public  boolean addUser(UserPOJO userPOJO){
        MultiUtil.startTask(() -> iDao.addUser(userPOJO));
        return true;
     }

    public  boolean modifyUser(UserPOJO userPOJO){
        return iDao.modifyUser(userPOJO);
    }

    public  boolean removeUser(UserPOJO userPOJO){
       return iDao.removeUser(userPOJO);
    }

    public  UserPOJO queryUser(UserPOJO userPOJO){
        return iDao.queryUser(userPOJO);
    }


    public  List<UserPOJO> queryAll(){
        PageHelper.startPage(2, 3);
//        Page{count=true, pageNum=2, pageSize=3, startRow=3, endRow=6, total=10021, pages=3341, reasonable=false, pageSizeZero=false}[{"id":"480", "name":"from k8s pod-4"}, {"id":"481", "name":"from k8s pod-5"}, {"id":"482", "name":"from k8s pod-6"}]

        return iDao.queryAll();
    }
}
